* Firm organization with multiple establishments
* Appendix A: Table A.19

clear all 
set matsize 2000
set more off

capture log close
log using log/32_facts-cs_org_layer-firm.log, replace

use "data/Org_2012_cs_layer-firm.dta", clear
count

qui tab jahr, gen(d_jhr)
gen ln_prdt_wkr_unt = log(prdt_wkrs_unt)

//	# FE: 256 (HQ: 244) wz 2008, 207 (201) wz 1993, 402 ao_kreis
global optSEest		"vce(cluster untid)"
global optSEHQ		"vce(cluster untid)"
global optGLM		"link(logit) family(binomial) nolog"
global opttab		"b(%9.3f) star(+ 0.10 * 0.05 ** 0.01 *** 0.001) compress mtitles style(tex) label"
global FEunt93	"d_93wz* d_hq_kreis* d_legal*" // d_93wz bezieht sich auf HQ Sektor
global FEunt08	"d_08wz* d_hq_kreis* d_legal*" // d_08wz bezieht sich auf HQ Sektor
global optMEcount	"vce(cluster hq_kreis)"

********************************************************************************
***	Firm-level analyses	********************************************************
********************************************************************************
cap drop flg_unt
cap drop flg_untjhr
egen flg_unt = tag(untid)
egen flg_untjhr = tag(untid jahr)
keep if flg_untjhr == 1

xtset, clear
sort untid jahr


estimates clear

gen shr_mgmt_w_unt_glm = shr_mgmt_w_unt / 100
sum shr_mgmt_w_unt_glm
label variable shr_mgmt_w_unt_glm "Managerial share in wage sum, layer"

gen shr_bloss_w_unt_glm = shr_bloss_w_unt / 100
sum shr_bloss_w_unt_glm
label variable shr_bloss_w_unt_glm "Managerial share in wage sum, Blossfeld"

********************************************************************************
***	Table A.19: Mg. organization of firm ***************************************

eststo col1, title("\# layers"): qui poisson count_mgmt_unt d_mbu					$FEunt08, $optMEcount
eststo col2, title("\# layers"): qui poisson count_mgmt_unt d_mbu ln_sales  		$FEunt08, $optMEcount
eststo col3, title("\# layers"): qui poisson count_mgmt_unt d_mbu ln_prdt_wkr_unt	$FEunt08, $optMEcount

eststo col4, title("Mg.share"): qui glm shr_mgmt_w_unt_glm d_mbu				 	$FEunt08, $optGLM $optMEcount

eststo col5, title("Mg.share"): qui glm shr_bloss_w_unt_glm  d_mbu					$FEunt08, $optGLM $optMEcount

esttab col1 col2 col3 col4 col5, ///
	$opttab se(%9.3f) indicate($FEunt08, labels(Y N)) drop(o.*) order(d_mbu ln_sales ln_prdt_wkr_unt)
esttab col1 col2 col3 col4 col5, ///
	$opttab p(%9.3f)  indicate($FEunt08, labels(Y N)) drop(o.*) order(d_mbu ln_sales ln_prdt_wkr_unt)

	
	
log close
